
//预加载图片
export async function PreLoadImages(paths: string[]) {
    let imageFetchCount: number = 0;
    return new Promise((resolve) => {
        paths.forEach((path: string) => {
            let i = new Image();
            i.src = path;
            i.onload = function () {
                imageFetchCount++;
                if (imageFetchCount >= paths.length) {
                    resolve(true);
                }
            };

            i.onerror = function (e) {
                // resolve(e);
                console.log("图片加载失败", e)
            };
        });
    });
}